//
//  ProductDetailViewController.m
//  UEAssistant
//
//  Created by mac on 2017/2/9.
//  Copyright © 2017年 youyixinxi. All rights reserved.
//

#import "FilesViewController.h"
#import "ProductDetailHeader.h"
#import "ProductDetModel.h"
#import "ProductDetailTableViewCell.h"
#import "NoticeView.h"
#import "SegProgressView.h"
#import "OrderDetailTableViewCell.h"
#import "ProgressViewOfProDD.h"
#import "ProductDetModel.h"
#import "AssigningViewController.h"
#import "TableViewCell.h"
#import "CancelTaskHud.h"
#import "IsureTaskHud.h"
#import "SMAlert.h"
#import "DeWeightViewController.h"
#import "SplitPageViewController.h"
#import <VTMagic.h>
#import "MJ_SelectTranslatorView.h"
#import "MJ_EditTaskInfoViewController.h"
@interface FilesViewController ()<UITableViewDelegate,UITableViewDataSource,UIScrollViewDelegate,FoldSectionHeaderViewDelegate,AssignTaskDelegate,cancelHudDelegate,IsureHudDelegate>{
    
    NSMutableArray                  *_dataSource;
    NSMutableDictionary             *_names_dic;/**< 译员名字 */
    CGFloat                         _prefrence_Width;
    CGFloat                         _tableView_head_static_height;
    NSMutableArray                  *_model_bool;
    NSMutableDictionary             *_face_dic;/**< 头像路径 */
    //记录译员页面选中状态（根据ID记录）
    NSInteger                       _trans_userId;/**< 翻译译员ID */
    NSInteger                       _edit_userId;/**< 编辑译员ID  */
    NSInteger                       _pro_userId;/**< 校对译员ID  */
    //取消自动派稿参数
    NSDictionary                    *_cancelParam;
    NSMutableArray                  *_selectAllModel;/**< 判断header是否能选择 */
    NSMutableArray                  *_selectFileModel;/**< header选中Model */
}

@property (nonatomic, strong) UITableView                   *tableView;
@property (nonatomic, strong) NSDictionary                  *foldInfoDic;/**< 存储开关 */
@property (nonatomic, strong) ProductDetModel               *model;
@property (nonatomic, strong) UITableView                   *tableView_head;
@property (nonatomic, strong) UILabel                       *tagLabel;
@property (nonatomic, strong) UILabel                       *tagLabeltwo;
@property (nonatomic, strong) UILabel                       *tagLabelThr;
@property (nonatomic, strong) UILabel                       *tagLabelFour;
@property (nonatomic, strong) NSArray                       *titles;
@property (nonatomic, strong) NSString                      *aotuString;
@property (nonatomic, assign) BOOL                          isAnnimationCell;
@property (nonatomic, assign) NSInteger                     index;
@property (nonatomic, strong) UILabel                       *titleL;
@property (nonatomic, assign) BOOL                          imagetrans_bool;
@property (nonatomic, strong) UIView                        *shadowView;
@property (nonatomic, strong) CancelTaskHud                 *cancelHud;
@property (nonatomic, strong) IsureTaskHud                  *isSureHud;
@property (nonatomic, strong) UIView                        *tempView;
@property (nonatomic, assign) BOOL                          PostEnd;
@property (nonatomic, strong) UILabel                       *DocStatuesText;
@property (nonatomic, strong) ProgressViewOfProDD           *progressView_All;
@property (nonatomic, strong) ProgressViewOfProDD           *progressView_proofread;
@property (nonatomic, strong) ProgressViewOfProDD           *progressView_edit;
@property (nonatomic, strong) ProgressViewOfProDD           *progressView_translate;
@property (nonatomic, strong) UIView                        *ToolsView;
@property (nonatomic, strong) UIImageView                   *view_data_nil;
@property (nonatomic, strong) UILabel                       *text_data_nil;

//MJ
@property (strong, nonatomic)UIButton *editButton;//编辑按钮
@property (strong, nonatomic)UIButton *selectAllButton;//全选
@property (strong, nonatomic)UIButton *selectNoneButton;//全不选
@property (strong, nonatomic)UIButton *cancelButton;//取消
@property (strong, nonatomic)UIButton *backButton;//返回按钮
@property (strong, nonatomic)MJ_SelectTranslatorView *selectTranslatorView;

@end

@implementation FilesViewController

- (MJ_SelectTranslatorView *)selectTranslatorView
{
    if (!_selectTranslatorView) {
        _selectTranslatorView = [[[NSBundle mainBundle] loadNibNamed:@"MJ_SelectTranslatorView" owner:nil options:nil]lastObject];
        _selectTranslatorView.frame = [UIScreen mainScreen].bounds;
        _selectTranslatorView.backgroundColor = [UIColor whiteColor];
    }
    return _selectTranslatorView;
}

- (UIButton *)editButton {
    if (!_editButton) {
        _editButton = [UIButton buttonWithType:UIButtonTypeCustom];
        UIImage *image = [UIImage imageNamed:@"choose"];
        [_editButton setImage:image forState:UIControlStateNormal];
        _editButton.contentMode = UIViewContentModeScaleToFill;
        _editButton.frame = CGRectMake(0, 0, 20, 20);
        [_editButton addTarget:self action:@selector(fileEditNofifiCationClicked) forControlEvents:UIControlEventTouchUpInside];
    }
    return _editButton;
}
- (UIButton *)selectAllButton {
    if (!_selectAllButton) {
        _selectAllButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_selectAllButton setTitle:@"全选" forState:UIControlStateNormal];
        _selectAllButton.titleLabel.font = [UIFont systemFontOfSize:14];
        [_selectAllButton setTitleColor:[UIColor colorWithHexString:@"#666666"] forState:UIControlStateNormal];
        [_selectAllButton addTarget:self action:@selector(fileSelectAllNofifiCationClicked) forControlEvents:UIControlEventTouchUpInside];
    }
    return _selectAllButton;
}
- (UIButton *)selectNoneButton {
    if (!_selectNoneButton) {
        _selectNoneButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_selectNoneButton setTitle:@"全不选" forState:UIControlStateNormal];
        _selectNoneButton.titleLabel.font = [UIFont systemFontOfSize:14];
        [_selectNoneButton setTitleColor:[UIColor colorWithHexString:@"#666666"] forState:UIControlStateNormal];
        [_selectNoneButton addTarget:self action:@selector(fileSelectZeroNofifiCationClicked) forControlEvents:UIControlEventTouchUpInside];
    }
    return _selectNoneButton;
}
- (UIButton *)cancelButton {
    if (!_cancelButton) {
        _cancelButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_cancelButton setTitle:@"取消" forState:UIControlStateNormal];
        _cancelButton.titleLabel.font = [UIFont systemFontOfSize:14];
        [_cancelButton setTitleColor:[UIColor colorWithHexString:@"#666666"] forState:UIControlStateNormal];
        [_cancelButton addTarget:self action:@selector(fileEditCancelNofifiCationClicked) forControlEvents:UIControlEventTouchUpInside];
    }
    return _cancelButton;
}
- (UIButton *)backButton {
    if (!_backButton) {
        _backButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_backButton setImage:[UIImage imageNamed:@"Nav_返回"] forState:UIControlStateNormal];
        _backButton.frame = CGRectMake(0, 0, 20, 20);
        [_backButton addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];
    }
    return _backButton;
}
- (void)back {
    [self.magicController.navigationController popViewControllerAnimated:YES];
}
- (void)dealloc{
    
    [[NSNotificationCenter defaultCenter]removeObserver:self name:@"AssignTaskSuccessAndRef" object:nil];
    [[NSNotificationCenter defaultCenter]removeObserver:self name:@"splitFileRefresh" object:nil];

}

- (void)viewWillAppear:(BOOL)animated{
    
    shareData.isProductDetail_Hud = YES;
    shareData.product_ispop = YES;

}

- (void)viewDidDisappear:(BOOL)animated{
    
    shareData.isProductDetail_Hud = NO;
}

- (void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:self.editButton];
    self.magicController.navigationItem.rightBarButtonItem = rightItem;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initlizeUserface];
    [self initlizeDataSource];
}

- (void)initlizeUserface{
    
    self.view.backgroundColor = [UIColor whiteColor];
    [self.tableView_head registerNib:[UINib nibWithNibName:@"OrderDetailTableViewCell" bundle:nil] forCellReuseIdentifier:orderDetailCell];
    
    [self.view addSubview:self.tableView];
    [YhxUtility setExtraCellLineHidden:self.tableView];

    _tableView_head.rowHeight =  UITableViewAutomaticDimension;
    _tableView_head.estimatedRowHeight = 35*Radio;
    
    [self.view addSubview:self.ToolsView];
    self.ToolsView.userInteractionEnabled = YES;
    
    UIImageView *deweightImage = [[UIImageView alloc]initWithFrame:CGRectMake(Screen_Width/6+7.5, 5, 25, 25)];
    deweightImage.image = [UIImage imageNamed:@"去重"];
    [self.ToolsView addSubview:deweightImage];

    UIImageView *deleteImage = [[UIImageView alloc]initWithFrame:CGRectMake(Screen_Width - Screen_Width/6-25-7.5, 5, 25, 25)];
    deleteImage.image = [UIImage imageNamed:@"删除"];
    [self.ToolsView addSubview:deleteImage];

    UIButton *deWeight = [UIButton buttonWithType:UIButtonTypeSystem];
    deWeight.frame = CGRectMake(Screen_Width/6, 30, 40, 20);
    deWeight.backgroundColor = [UIColor clearColor];
    [deWeight setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [deWeight setTitle:@"去重" forState:UIControlStateNormal];
    [deWeight addTarget:self action:@selector(deweightFilesResquest) forControlEvents:UIControlEventTouchUpInside];
    deWeight.titleLabel.font = [UIFont systemFontOfSize:14];
    [deWeight setEnlargeEdgeWithTop:25 right:5 bottom:0 left:5];
    [self.ToolsView addSubview:deWeight];

    UIButton *deleteFiles = [UIButton buttonWithType:UIButtonTypeCustom];
    deleteFiles.frame = CGRectMake(Screen_Width-Screen_Width/6-40, 30, 40, 20);
    deleteFiles.backgroundColor = [UIColor clearColor];
    [deleteFiles setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [deleteFiles setTitle:@"删除" forState:UIControlStateNormal];
    [deleteFiles addTarget:self action:@selector(deleteFilesResquest) forControlEvents:UIControlEventTouchUpInside];
    deleteFiles.titleLabel.font = [UIFont systemFontOfSize:14];
    [deleteFiles setEnlargeEdgeWithTop:25 right:5 bottom:0 left:5];
    [self.ToolsView addSubview:deleteFiles];
    
    self.magicController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.backButton];
    UIBarButtonItem *rightItem = [[UIBarButtonItem alloc] initWithCustomView:self.editButton];
    self.magicController.navigationItem.rightBarButtonItem = rightItem;
}


- (void)initlizeDataSource{

    [self addNotification];
    
    _face_dic = [NSMutableDictionary dictionary];
    _model_bool = [NSMutableArray array];
    _imagetrans_bool = NO;
    _names_dic = [NSMutableDictionary dictionary];
    _foldInfoDic = [NSMutableDictionary dictionary];
    _selectAllModel = [NSMutableArray array];
    _selectFileModel = [NSMutableArray array];
    _trans_userId = 0;
    _edit_userId = 0;
    _pro_userId = 0;
    
    //tableView适配特殊处理
    if (Screen_Width == 320) {
        _tableView_head_static_height = 355.9;
        _prefrence_Width = 160;
    }else if (Screen_Width == 375){
        _tableView_head_static_height = 370;
        _prefrence_Width = 215;
    }else{
        _tableView_head_static_height = 370;
        _prefrence_Width = 254;
    }
    
    if (((NSString *)(detailsModel.dataSource_head[5])).length == 0) {
        _aotuString = @"无备注信息";
    }else{
        _aotuString = detailsModel.dataSource_head[5];
    }
    _isAnnimationCell = YES;
    _dataSource = [NSMutableArray array];
    [detailsModel.dataSource_head enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        
        if ([obj isEqualToString:@""]) {
            [detailsModel.dataSource_head replaceObjectAtIndex:idx withObject:@"- -"];
        }
    }];
    
#pragma mark -- 开始请求部分数据
    [LSProgressHUD showLoadingToView:self.parentViewController.view];
    [self getFinderListRequest];
}

- (void)addNotification{

    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(assignTaskSucRefresh) name:@"AssignTaskSuccessAndRef" object:nil];
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(splitFileRefreshClicked) name:@"splitFileRefresh" object:nil];
}

#pragma mark -- 文件操作成功后返回刷新界面
- (void)assignTaskSucRefresh{
    
    //刷新数据--
    [_dataSource removeAllObjects];
    [self getFinderListRequest];
    [TopAlertView SetUpbackgroundColor:mainColor andStayTime:2.0 andImageName:@"imagePlaceholder" andTitleStr:@"操作成功" andTitleColor:[UIColor whiteColor] andCancel:NO];
}

- (void)splitFileRefreshClicked{

    //刷新数据--
    [_dataSource removeAllObjects];
    [self getFinderListRequest];
    [TopAlertView SetUpbackgroundColor:mainColor andStayTime:2.0 andImageName:@"imagePlaceholder" andTitleStr:@"拆分文件成功" andTitleColor:[UIColor whiteColor] andCancel:NO];

}

#pragma mark -- 文件内容
- (void)getFinderListRequest{
    
    NSDictionary *dic = @{@"projectId":shareData.product_Id};
    [AvailableNetWorking postWithUrl:productDetail_connector params:dic successHandler:^(id responseObject) {
        
//        NSLog(@"productDetail ---  %@",responseObject);
        if ([responseObject[@"code"] intValue] == 200) {
            
            [_dataSource addObjectsFromArray:responseObject[@"result"]];
            NSDictionary *dicNew = @{@"teamId":detailsModel.ownerId};
            [self getUserNameWithDic:dicNew];
            shareData.fileEditEnable = YES;
        }
        else{
            [LSProgressHUD hiddenLoading:self.parentViewController.view];
            _PostEnd = YES;
            self.tableView.backgroundColor = [UIColor whiteColor];
            [self.tableView reloadData];
            [self.tableView addSubview:self.view_data_nil];
            [self.tableView addSubview:self.text_data_nil];
            shareData.fileEditEnable = NO;
        }
        
    } falureHandler:^(NSError *error) {
        
        [LSProgressHUD hiddenLoading:self.parentViewController.view];
        _PostEnd = YES;
        [self.tableView reloadData];
        self.tableView.backgroundColor = [UIColor whiteColor];
        
        
    }];
}

#pragma mark -- 所有参与人名字
- (void)getUserNameWithDic:(NSDictionary *)dic{
    
    [AvailableNetWorking postWithUrl:TeamTranslaters_connector params:dic successHandler:^(id responseObject) {
        
        NSLog(@"username -- %@",responseObject[@"message"]);
//        NSLog(@" productUser --- %@",responseObject);
        
        //插入名字
        if (![responseObject[@"result"] isEqual:[NSNull null]]) {
            NSArray *sourceArr = responseObject[@"result"];
            if (sourceArr.count != 0) {
                
                NSLog(@"sourceArr =============  %@",sourceArr);
                [sourceArr enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                    
                    if ([[obj allKeys] containsObject:@"facePath"]) {
                        [_face_dic setObject:obj[@"facePath"] forKey:obj[@"userId"]];
                    }
                    if ([[obj allKeys] containsObject:@"userRemark"]) {
                        if (![obj[@"userRemark"] isEqualToString:@""]) {
                            [_names_dic setObject:[self judgeNullUserIdWithObj:obj[@"userRemark"]] forKey:obj[@"userId"]];
                        }else{
                            [_names_dic setObject:[self judgeNullUserIdWithObj:obj[@"nickName"]] forKey:obj[@"userId"]];
                        }
                    }else if ([[obj allKeys] containsObject:@"nickName"]) {
                        [_names_dic setObject:[self judgeNullUserIdWithObj:obj[@"nickName"]] forKey:obj[@"userId"]];
                    }
                    else{
                        [_names_dic setObject:@"无对应字段" forKey:obj[@"userId"]];
                    }
                }];
            }
            else{
                //没得参与者名字
            }
        }
        else{
            //初始化用户团队失败
        }
        
        [_selectAllModel removeAllObjects];
        [_dataSource enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
            [_selectAllModel addObject:@"0"];
        }];
        [_dataSource addObject:_names_dic];
        [_dataSource addObject:_face_dic];
        self.tableView.backgroundColor = [UIColor whiteColor];
        [LSProgressHUD hiddenLoading:self.parentViewController.view];
        _PostEnd = YES;
        [self.tableView reloadData];
        
    } falureHandler:^(NSError *error) {
        
        _PostEnd = YES;
        self.tableView.backgroundColor = [UIColor whiteColor];
        [LSProgressHUD hiddenLoading:self.parentViewController.view];

        [self.tableView reloadData];
        NSLog(@"productUserError%@",error);
    }];
    
}

#pragma mark -- delegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    
    if (tableView == self.tableView) {
        //因为数据源最后一个对象是插入的名字字典，所以原本该+1的现在不+1了。
        if (_dataSource.count == 0 && _PostEnd) {
            return 1;
        }else{
            return _dataSource.count - 1;
        }
    }
    else{
        return 1;
    }
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    if (tableView == self.tableView) {
        if (section == 0) {
            return 0;
        }
        else{
            NSString *key = [NSString stringWithFormat:@"%d", (int)section];
            BOOL folded = [[_foldInfoDic objectForKey:key] boolValue];
            if ([self judgeRowInsectionWithData:_dataSource[section -1] section:section -1] == 1) {
                [_model_bool addObject:@"0"];
            }else{
                [_model_bool addObject:@"1"];
            }
            return folded ? [self judgeRowInsectionWithData:_dataSource[section -1] section:section -1] : 0;
            
        }
    }
    else{
        
        return 6;
    }
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    if (tableView == self.tableView) {
        
        TableViewCell *cell = [[TableViewCell alloc]initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"cell"];
        
        NSMutableParagraphStyle *paraStyle01 = [[NSMutableParagraphStyle alloc] init];
        paraStyle01.alignment = NSTextAlignmentLeft;  //对齐
        paraStyle01.headIndent = 18.f;//行首缩进
        paraStyle01.firstLineHeadIndent = 18.f;//首行缩进
        paraStyle01.lineSpacing = 2.0f;//行间距
        
        if (((NSArray *)_dataSource[indexPath.section - 1][@"result"]).count == 0) {
            NSString *fileNameText = _dataSource[indexPath.section - 1][@"doc_name"];
            NSAttributedString *attrText = [[NSAttributedString alloc] initWithString:fileNameText attributes:@{NSParagraphStyleAttributeName:paraStyle01}];
            cell.fileName.attributedText = attrText;
            cell.nameTrans.text = [self judeNameWithString:[_dataSource[_dataSource.count - 2] objectForKey:_dataSource[indexPath.row][@"interpreterUserId"]]];
            cell.nameEdit.text = [self judeNameWithString:[_dataSource[_dataSource.count - 2] objectForKey:_dataSource[indexPath.row][@"editUserId"]]];
            cell.namePro.text = [self judeNameWithString:[_dataSource[_dataSource.count - 2] objectForKey:_dataSource[indexPath.row][@"proofreadUserId"]]];
            cell.wordCountTrans.text = [NSString stringWithFormat:@"%@字",_dataSource[indexPath.row][@"tranWordcount"]];
            cell.wordCountEdit.text = [NSString stringWithFormat:@"%@字",_dataSource[indexPath.row][@"editWordcount"]];
            cell.wordCountPro.text = [NSString stringWithFormat:@"%@字",_dataSource[indexPath.row][@"proofWordcount"]];
            
            cell.timeTrans.text = [self judeNullWithString:_dataSource[indexPath.row][@"interpreterCompleteTime"]];
            cell.timeEdit.text = [self judeNullWithString:_dataSource[indexPath.row][@"editCompleteTime"]];
            cell.timePro.text = [self judeNullWithString:_dataSource[indexPath.row][@"proofreadCompleteTime"]];
            [cell setProgressTrans:floorf([self judeNullFloatWithString:
                                           _dataSource[indexPath.row][@"transtask_finishper"]]*100)/100
                              edit:floorf([self judeNullFloatWithString:
                                           _dataSource[indexPath.row][@"edittask_finishper"]]*100)/100
                               pro:floorf([self judeNullFloatWithString:
                                           _dataSource[indexPath.row][@"prooftask_finishper"]]*100)/100];
            
            [cell.headViewTrans sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",headImageViewOSS,[_dataSource.lastObject objectForKey:_dataSource[indexPath.row][@"interpreterUserId"]]]] placeholderImage:[UIImage imageNamed:@"user"]];
            [cell.headViewEdit sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",headImageViewOSS,[_dataSource.lastObject objectForKey:_dataSource[indexPath.row][@"editUserId"]]]] placeholderImage:[UIImage imageNamed:@"user"]];
            [cell.headViewPro sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",headImageViewOSS,[_dataSource.lastObject objectForKey:_dataSource[indexPath.row][@"proofreadUserId"]]]] placeholderImage:[UIImage imageNamed:@"user"]];
            
            if ([_dataSource[indexPath.row][@"interpreterUserId"] integerValue] == -1 ) {
                [cell.ButtonTrans setTitle:@"派稿中..." forState:UIControlStateNormal];
            }else{
                [cell.ButtonTrans setTitle:@"指派翻译" forState:UIControlStateNormal];
            }
            
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.delegate = self;
            
        }else{
            
            NSString *fileNameText = _dataSource[indexPath.section - 1][@"result"][indexPath.row][@"sectorname"];
            NSAttributedString *attrText = [[NSAttributedString alloc] initWithString:fileNameText attributes:@{NSParagraphStyleAttributeName:paraStyle01}];
            cell.fileName.attributedText = attrText;
            cell.nameTrans.text = [self judeNameWithString:[_dataSource[_dataSource.count - 2] objectForKey:_dataSource[indexPath.section - 1][@"result"][indexPath.row][@"interpreterUserId"]]];
            cell.nameEdit.text = [self judeNameWithString:[_dataSource[_dataSource.count - 2] objectForKey:_dataSource[indexPath.section - 1][@"result"][indexPath.row][@"editUserId"]]];
            cell.namePro.text = [self judeNameWithString:[_dataSource[_dataSource.count - 2] objectForKey:_dataSource[indexPath.section - 1][@"result"][indexPath.row][@"proofreadUserId"]]];
            
            cell.wordCountTrans.text = [NSString stringWithFormat:@"%@字",_dataSource[indexPath.section- 1][@"result"][indexPath.row][@"tranWordcount"]];
            cell.wordCountEdit.text = [NSString stringWithFormat:@"%@字",_dataSource[indexPath.section- 1][@"result"][indexPath.row][@"editWordcount"]];
            cell.wordCountPro.text = [NSString stringWithFormat:@"%@字",_dataSource[indexPath.section- 1][@"result"][indexPath.row][@"proofWordcount"]];
            cell.timeTrans.text = [self judeNullWithString:_dataSource[indexPath.section- 1][@"result"][indexPath.row][@"interpreterCompleteTime"]];
            cell.timeEdit.text = [self judeNullWithString:_dataSource[indexPath.section- 1][@"result"][indexPath.row][@"editCompleteTime"]];
            cell.timePro.text = [self judeNullWithString:_dataSource[indexPath.section- 1][@"result"][indexPath.row][@"proofreadCompleteTime"]];
            
            [cell setProgressTrans:floorf([self judeNullFloatWithString:
                                           _dataSource[indexPath.section- 1][@"result"][indexPath.row][@"transtask_finishper"]]*100)/100
                              edit:floorf([self judeNullFloatWithString:
                                           _dataSource[indexPath.section- 1][@"result"][indexPath.row][@"edittask_finishper"]]*100)/100
                               pro:floorf([self judeNullFloatWithString:
                                           _dataSource[indexPath.section- 1][@"result"][indexPath.row][@"prooftask_finishper"]]*100)/100];
            
            [cell.headViewTrans sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",headImageViewOSS,[_dataSource.lastObject objectForKey:_dataSource[indexPath.section - 1][@"result"][indexPath.row][@"interpreterUserId"]]]] placeholderImage:[UIImage imageNamed:@"user"]];
            [cell.headViewEdit sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",headImageViewOSS,[_dataSource.lastObject objectForKey:_dataSource[indexPath.section - 1][@"result"][indexPath.row][@"editUserId"]]]] placeholderImage:[UIImage imageNamed:@"user"]];
            [cell.headViewPro sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@",headImageViewOSS,[_dataSource.lastObject objectForKey:_dataSource[indexPath.section - 1][@"result"][indexPath.row][@"proofreadUserId"]]]] placeholderImage:[UIImage imageNamed:@"user"]];
            
            if ([_dataSource[indexPath.section - 1][@"result"][indexPath.row][@"interpreterUserId"] integerValue] == -1 ) {
                [cell.ButtonTrans setTitle:@"派稿中..." forState:UIControlStateNormal];
            }else{
                [cell.ButtonTrans setTitle:@"指派翻译" forState:UIControlStateNormal];
            }
            
            cell.selectionStyle = UITableViewCellSelectionStyleNone;
            cell.delegate = self;
        }
        //修改约束
        if ([cell.nameTrans.text isEqualToString:@"未指派"]) {
            
            [cell.nameTrans removeFromSuperview];
            [cell.nameEdit removeFromSuperview];
            [cell.namePro removeFromSuperview];
            [cell.wordCountTrans removeFromSuperview];
            [cell.wordCountEdit removeFromSuperview];
            [cell.wordCountPro removeFromSuperview];
            [cell.timeTrans removeFromSuperview];
            [cell.timeEdit removeFromSuperview];
            [cell.timePro removeFromSuperview];
            [cell.ButtonTrans setCenter:CGPointMake(cell.headViewTrans.center.x, cell.headViewTrans.center.y+50*Radio)];
            [cell.ButtonEdit setCenter:CGPointMake(cell.headViewEdit.center.x, cell.headViewTrans.center.y+50*Radio)];
            [cell.ButtonPro setCenter:CGPointMake(cell.headViewPro.center.x, cell.headViewTrans.center.y+50*Radio)];
            tableView.rowHeight = 160*Radio;
            if (((NSArray *)_dataSource[indexPath.section - 1][@"result"]).count == 0) {
                UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, 160*Radio-0.6, Screen_Width, 0.6)];
                line.backgroundColor = [UIColor colorWithWhite:0.8 alpha:1];
                [cell addSubview:line];
            }else{
                if (indexPath.row == ((NSArray *)_dataSource[indexPath.section - 1][@"result"]).count-1) {
                    UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, 160*Radio-0.6, Screen_Width, 0.6)];
                    line.backgroundColor = [UIColor colorWithWhite:0.8 alpha:1];
                    [cell addSubview:line];
                }
            }
        }else if ([cell.nameEdit.text isEqualToString:@"未指派"]){
            
            cell.nameEdit.backgroundColor = [UIColor clearColor];
            cell.nameEdit.textColor = [UIColor clearColor];
            cell.namePro.backgroundColor = [UIColor clearColor];
            cell.namePro.textColor = [UIColor clearColor];
            [cell.wordCountEdit removeFromSuperview];
            [cell.wordCountPro removeFromSuperview];
            [cell.timeEdit removeFromSuperview];
            [cell.timePro removeFromSuperview];
            tableView.rowHeight = 230*Radio;
            if (((NSArray *)_dataSource[indexPath.section - 1][@"result"]).count == 0) {
                UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, 230*Radio-0.6, Screen_Width, 0.6)];
                line.backgroundColor = [UIColor colorWithWhite:0.8 alpha:1];
                [cell addSubview:line];
            }else{
                if (indexPath.row == ((NSArray *)_dataSource[indexPath.section - 1][@"result"]).count-1) {
                    UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, 230*Radio-0.6, Screen_Width, 0.6)];
                    line.backgroundColor = [UIColor colorWithWhite:0.8 alpha:1];
                    [cell addSubview:line];
                }
            }
        }else if ([cell.namePro.text isEqualToString:@"未指派"]){
            
            cell.namePro.backgroundColor = [UIColor clearColor];
            cell.namePro.textColor = [UIColor clearColor];
            [cell.wordCountPro setHidden:YES];
            [cell.timePro removeFromSuperview];
            tableView.rowHeight = 230*Radio;
            if (((NSArray *)_dataSource[indexPath.section - 1][@"result"]).count == 0) {
                UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, 230*Radio-0.6, Screen_Width, 0.6)];
                line.backgroundColor = [UIColor colorWithWhite:0.8 alpha:1];
                [cell addSubview:line];
            }else{
                if (indexPath.row == ((NSArray *)_dataSource[indexPath.section - 1][@"result"]).count-1) {
                    UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, 230*Radio-0.6, Screen_Width, 0.6)];
                    line.backgroundColor = [UIColor colorWithWhite:0.8 alpha:1];
                    [cell addSubview:line];
                }
            }
        }
        else{
            
            tableView.rowHeight = 230*Radio;
            if (((NSArray *)_dataSource[indexPath.section - 1][@"result"]).count == 0) {
                UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, 230*Radio-0.6, Screen_Width, 0.6)];
                line.backgroundColor = [UIColor colorWithWhite:0.8 alpha:1];
                [cell addSubview:line];
            }else{
                if (indexPath.row == ((NSArray *)_dataSource[indexPath.section - 1][@"result"]).count-1) {
                    UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, 230*Radio-0.6, Screen_Width, 0.6)];
                    line.backgroundColor = [UIColor colorWithWhite:0.8 alpha:1];
                    [cell addSubview:line];
                }
            }
        }
        
        if ([_dataSource[indexPath.section - 1][@"docStatus"] integerValue] < 0 || [_dataSource[indexPath.section - 1][@"docStatus"] integerValue] > 4) {
            [cell.subviews enumerateObjectsUsingBlock:^(__kindof UIView * _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                [obj removeFromSuperview];
            }];
            _DocStatuesText = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, Screen_Width, 50*Radio)];
            _DocStatuesText.backgroundColor = [UIColor colorWithWhite:1 alpha:0];
            _DocStatuesText.textColor = RGB(51, 51, 51, 1);
            _DocStatuesText.numberOfLines = 0;
            _DocStatuesText.font = [UIFont systemFontOfSize:FLEXIBLE(15)];
            _DocStatuesText.textAlignment = NSTextAlignmentCenter;
            _DocStatuesText.text = @"改文件出现异常，请到网页上查看详情";
            [cell addSubview:_DocStatuesText];
            tableView.rowHeight = 50*Radio;
            UIView *line = [[UIView alloc]initWithFrame:CGRectMake(0, 50*Radio-0.5, Screen_Width, 0.5)];
            line.backgroundColor = [UIColor colorWithWhite:0.8 alpha:1];
            [cell addSubview:line];
        }
        switch ([_dataSource[indexPath.section - 1][@"docStatus"] integerValue]) {
            case 7:
            {
                _DocStatuesText.text = @"文件未导入";
            }
                break;
            case 8:
            {
                _DocStatuesText.text = @"文件导入失败";
            }
                break;
            case 9:
            {
                _DocStatuesText.text = @"文件上传失败";
            }
                break;
            case 10:
            {
                _DocStatuesText.text = @"文件解析中...";
            }
                break;
            case 11:
            {
                _DocStatuesText.text = @"文件导入中...";
            }
                break;
            default:
                break;
        }
        return cell;
        
    }
    else{
        
        OrderDetailTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:orderDetailCell];
        cell.selectionStyle = UITableViewCellSelectionStyleNone;
        
        return cell;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    
    if (tableView == self.tableView) {
        
        if (section == 0) {
            
            return 0.001f;
        }
        else{
            return 40 + 18 + [self autoCalculateWidthOrHeight:MAXFLOAT width:Screen_Width-140 fontsize:FLEXIBLE(18) content:[_dataSource[section - 1][@"doc_name"] stringByReplacingOccurrencesOfString:@" " withString:@""]];
        }
    }
    else{
        
        return 0.001f;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{

    return 0.001f;
}

//头部视图
- (nullable UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
    
    if (tableView == self.tableView) {
        if (section == 0) {
            
            UIView *view = nil;
            return view;
        }
        else{

            ProductDetailHeader *headerView = [[ProductDetailHeader alloc] initWithReuseIdentifier:@"header"];
            [headerView setFoldSectionHeaderViewWithTitle:[_dataSource[section - 1][@"doc_name"] stringByReplacingOccurrencesOfString:@" " withString:@""] detail:[NSString stringWithFormat:@"%@",_dataSource[section - 1][@"wordcount"]]section:section canFold:YES canSelect:[_selectAllModel[section - 1] boolValue]height:[self autoCalculateWidthOrHeight:MAXFLOAT width:Screen_Width-140 fontsize:FLEXIBLE(18) content:[_dataSource[section - 1][@"doc_name"] stringByReplacingOccurrencesOfString:@" " withString:@""]]];

            headerView.delegate = self;
            headerView.typeImage.image = [UIImage imageNamed:[self judgeTypeWithName:_dataSource[section - 1][@"doc_name"]]];
            
            NSString *key = [NSString stringWithFormat:@"%d", (int)section];
            BOOL folded = [[_foldInfoDic valueForKey:key] boolValue];
            headerView.fold = folded;
            [headerView swipeToRightForSelect];
            if (_selectFileModel.count > 0 && [_selectFileModel[section - 1] integerValue] == 0 ) {
                headerView.seletImage.image = [UIImage imageNamed:@"选择"];
            }else{
                headerView.seletImage.image = [UIImage imageNamed:@"选中"];
            }
            return headerView;
        }
        
    }
    else{
        
        UIView *view = nil;
        return view;
    }
}


//判断该文件能不能进行操作
- (BOOL)ifCanGoOnNextStepOpretionWithNum:(NSInteger)num{
    
    if ([detailsModel.nowStep integerValue] > 0 && [detailsModel.nowStep integerValue] < 5) {
        
        [TopAlertView SetUpbackgroundColor:AlertRedColor andStayTime:2.0 andImageName:@"imagePlaceholder" andTitleStr:@"该项目还在流程中，不能拆分" andTitleColor:[UIColor whiteColor] andCancel:NO];
        return NO;
    }
    if ([_dataSource[num - 1][@"isPay"] integerValue]  == 1 && [_dataSource[num - 1][@"payStatus"] integerValue] == 0){
        
        [TopAlertView SetUpbackgroundColor:AlertRedColor andStayTime:2.0 andImageName:@"imagePlaceholder" andTitleStr:@"该文档付费后，才能拆分。" andTitleColor:[UIColor whiteColor] andCancel:NO];
        return NO;
    }
    if ([_dataSource[num - 1][@"isPay"] integerValue]  == 1 && [_dataSource[num - 1][@"payStatus"] integerValue] == 2){
        
        [TopAlertView SetUpbackgroundColor:AlertRedColor andStayTime:2.0 andImageName:@"imagePlaceholder" andTitleStr:@"该文档付费后，才能拆分。" andTitleColor:[UIColor whiteColor] andCancel:NO];
        return NO;
    }
    switch ([_dataSource[num - 1][@"docStatus"] integerValue]) {
        case 7:
        {
            [TopAlertView SetUpbackgroundColor:AlertRedColor andStayTime:2.0 andImageName:@"imagePlaceholder" andTitleStr:@"文件未导入" andTitleColor:[UIColor whiteColor] andCancel:NO];
            return NO;
        }
            break;
        case 8:
        {
            [TopAlertView SetUpbackgroundColor:AlertRedColor andStayTime:2.0 andImageName:@"imagePlaceholder" andTitleStr:@"文件导入失败" andTitleColor:[UIColor whiteColor] andCancel:NO];
            return NO;
        }
            break;
        case 9:
        {
            [TopAlertView SetUpbackgroundColor:AlertRedColor andStayTime:2.0 andImageName:@"imagePlaceholder" andTitleStr:@"文件上传失败" andTitleColor:[UIColor whiteColor] andCancel:NO];
            return NO;
        }
            break;
        case 10:
        {
            [TopAlertView SetUpbackgroundColor:AlertRedColor andStayTime:2.0 andImageName:@"imagePlaceholder" andTitleStr:@"文件解析中..." andTitleColor:[UIColor whiteColor] andCancel:NO];
            return NO;
        }
            break;
        case 11:
        {
            [TopAlertView SetUpbackgroundColor:AlertRedColor andStayTime:2.0 andImageName:@"imagePlaceholder" andTitleStr:@"文件导入中..." andTitleColor:[UIColor whiteColor] andCancel:NO];
            return NO;
        }
            break;
        default:
            break;
    }
    
    return YES;

}

#pragma mark -- notificationMethod
//编辑
- (void)fileEditNofifiCationClicked{
    
    [UIView animateWithDuration:0.2 animations:^{
        self.ToolsView.frame = CGRectMake(0, Screen_Height-64-40-50, Screen_Width, 50);
    }];
    [_selectFileModel removeAllObjects];
    [_selectAllModel enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        [_selectAllModel replaceObjectAtIndex:idx withObject:@"1"];
        [_selectFileModel addObject:@"0"];
    }];
//    TGLog(@"_selectFileModel_new == %@",_selectFileModel);
    self.tableView.frame = CGRectMake(0, 0, Screen_Width, Screen_Height-103-50);
    self.magicController.title = @"已选择0个文件";
    self.magicController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.selectAllButton];
    self.magicController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.cancelButton];
    [self.tableView reloadData];
}

//取消编辑
- (void)fileEditCancelNofifiCationClicked{
    
    [UIView animateWithDuration:0.2 animations:^{
        self.ToolsView.frame = CGRectMake(0, Screen_Height-104, Screen_Width, 50);
    }];
    [_selectAllModel enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        [_selectAllModel replaceObjectAtIndex:idx withObject:@"0"];
        if (_selectFileModel.count != 0) {
            [_selectFileModel replaceObjectAtIndex:idx withObject:@"0"];
        }
    }];
    self.magicController.title = detailsModel.productName;
    self.magicController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.backButton];
    self.magicController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.editButton];
    self.tableView.frame = CGRectMake(0, 0, Screen_Width, Screen_Height-103);
    [self.tableView reloadData];
}

//全不选
- (void)fileSelectZeroNofifiCationClicked{
    
    [_selectFileModel enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        [_selectFileModel replaceObjectAtIndex:idx withObject:@"0"];
    }];
    [self.tableView reloadData];
    self.magicController.title = @"已选择0个文件";
    self.magicController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.selectAllButton];
    self.magicController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.cancelButton];
}

//全选
- (void)fileSelectAllNofifiCationClicked{
    __block int files = 0;
    [_selectFileModel enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        [_selectFileModel replaceObjectAtIndex:idx withObject:@"1"];
        files ++;
    }];
    self.magicController.title = [NSString stringWithFormat:@"已选择%d个文件",files];
    self.magicController.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.selectNoneButton];
    self.magicController.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.cancelButton];
    [self.tableView reloadData];

}


//批量去重
- (void)deweightFilesResquest{
    
    //拼接所选文件的id
    NSMutableArray *idArr = [NSMutableArray array];
    NSMutableArray *nameArr = [NSMutableArray array];
    NSString *idString;
    NSString *nameString;
    [_selectFileModel enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        if ([obj isEqualToString:@"1"]) {
            [idArr addObject:_dataSource[idx][@"doc_id"]];
            [nameArr addObject:[_dataSource[idx][@"doc_name"] componentsSeparatedByString:@"."].lastObject];
        }
    }];
    
    if (idArr.count == 0) {
        [TopAlertView SetUpbackgroundColor:mainColor andStayTime:2.0 andImageName:@"imagePlaceholder" andTitleStr:@"请选择需要去重的文件" andTitleColor:[UIColor whiteColor] andCancel:NO];
    }else{
        idString = [idArr componentsJoinedByString:@","];
        nameString = [nameArr componentsJoinedByString:@","];
        DeWeightViewController *vc = [[DeWeightViewController alloc]init];
        vc.doc_id = idString;
        vc.doc_name_suffix = nameString;
        [self.navigationController pushViewController:vc animated:YES];
    }
}

//批量删除
- (void)deleteFilesResquest{
    
    NSMutableArray *idArr = [NSMutableArray array];
    [_selectFileModel enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        
        if ([obj isEqualToString:@"1"]) {
            [idArr addObject:_dataSource[idx][@"doc_id"]];
        }
    }];
    if (idArr.count == 0) {
        [TopAlertView SetUpbackgroundColor:mainColor andStayTime:2.0 andImageName:@"imagePlaceholder" andTitleStr:@"请选择需要删除的文件" andTitleColor:[UIColor whiteColor] andCancel:NO];
    }else{
        TGLog(@"delate Data == %@",_selectFileModel);
        [SMAlert setAlertBackgroundColor:[UIColor colorWithWhite:0 alpha:0.6]];
        [SMAlert setContentTextColor:RGB(51, 51, 51, 1)];
        [SMAlert setConfirmBtTitleColor:RGB(232, 89, 91, 1)];
        [SMAlert setCancleBtTitleColor:mainColor];
        [SMAlert setContentFont:[UIFont systemFontOfSize:FLEXIBLE(17)]];
        [SMAlert showContent:@"是否确认删除选中的全部文件" confirmButton:[SMButton initWithTitle:@"确定" clickAction:^{
            [SMAlert hide];
            [self WhenDeleteDocGetUUIDWithSec:1000 batch:YES];
            
        }]cancleButton:[SMButton initWithTitle:@"取消" clickAction:nil]];

    }
}


#pragma mark -- <FoldSectionHeaderViewDelegate>

- (void)foldHeaderInSection:(NSInteger)SectionHeader {
    
    NSString *key = [NSString stringWithFormat:@"%d",(int)SectionHeader];
    BOOL folded = [[_foldInfoDic objectForKey:key] boolValue];
    NSString *fold = folded ? @"0" : @"1";
    [_foldInfoDic setValue:fold forKey:key];
    [self.tableView reloadData];
}


- (void)extensionButtonInSection:(NSInteger)SectionHeader tag:(NSInteger)tag{

    self.parentViewController.hidesBottomBarWhenPushed = YES;
    switch (tag) {
        case 800://去重
        {
            DeWeightViewController *vc = [[DeWeightViewController alloc]init];
            vc.doc_id = [NSString stringWithFormat:@"%@",_dataSource[SectionHeader - 1][@"doc_id"]];
            vc.doc_name_suffix = [_dataSource[SectionHeader - 1][@"doc_name"] componentsSeparatedByString:@"."].lastObject;
            [self.navigationController pushViewController:vc animated:YES];
        }
            break;
        case 860://拆分
        {
            if ([self ifCanGoOnNextStepOpretionWithNum:SectionHeader]) {
                SplitPageViewController *vc = [[SplitPageViewController alloc]init];
                vc.doc_name = _dataSource[SectionHeader - 1][@"doc_name"];
                vc.doc_id = [NSString stringWithFormat:@"%@",_dataSource[SectionHeader - 1][@"doc_id"]];
                vc.wordCount = [NSString stringWithFormat:@"%@",_dataSource[SectionHeader - 1][@"wordcount"]];
                vc.doc_status = [NSString stringWithFormat:@"%@",_dataSource[SectionHeader - 1][@"docStatus"]];
                [self.navigationController pushViewController:vc animated:YES];
            }
        }
            break;
        case 920://删除
        {
            [SMAlert setAlertBackgroundColor:[UIColor colorWithWhite:0 alpha:0.6]];
            [SMAlert setContentTextColor:RGB(51, 51, 51, 1)];
            [SMAlert setConfirmBtTitleColor:RGB(232, 89, 91, 1)];
            [SMAlert setCancleBtTitleColor:mainColor];
            [SMAlert setContentFont:[UIFont systemFontOfSize:FLEXIBLE(17)]];
            [SMAlert showContent:[NSString stringWithFormat:@"是否确认删除该文件:\n%@",_dataSource[SectionHeader - 1][@"doc_name"]] confirmButton:[SMButton initWithTitle:@"确定" clickAction:^{
                [SMAlert hide];
                [self WhenDeleteDocGetUUIDWithSec:SectionHeader batch:NO];
                
            }]cancleButton:[SMButton initWithTitle:@"取消" clickAction:nil]];
        }
            break;
        default:
            break;
    }
    
}

- (void)selectHeaderSection:(NSInteger)section{

    if ([_selectFileModel[section - 1] integerValue] == 0) {
        [_selectFileModel replaceObjectAtIndex:section -1 withObject:@"1"];
    }else{
        [_selectFileModel replaceObjectAtIndex:section -1 withObject:@"0"];
    }
    __block int files = 0;
    [_selectFileModel enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        if ([obj isEqualToString:@"1"]) {
            files ++;
        }
    }];
    self.magicController.title = [NSString stringWithFormat:@"已选择%d个文件",files];
//    [[NSNotificationCenter defaultCenter]postNotificationName:@"changeFiles" object:];
    [self.tableView reloadData];
}


//删除文件(批量或者是单个)
- (void)WhenDeleteDocGetUUIDWithSec:(NSInteger)sec batch:(BOOL)batch{
   
    [LSProgressHUD showWithMessage:@"删除中..."];
    NSDictionary *params;
    if (batch) {
        //拼接所选文件的id
        NSMutableArray *idArr = [NSMutableArray array];
        NSString *idString;
        [_selectFileModel enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
           
            if ([obj isEqualToString:@"1"]) {
                [idArr addObject:_dataSource[idx][@"doc_id"]];
            }
        }];
        TGLog(@"idString == %@",idString);
        idString = [idArr componentsJoinedByString:@","];
        params = @{@"projectId":detailsModel.product_Id,
                   @"transdocId":idString};
    }else{
        params = @{@"projectId":detailsModel.product_Id,
                   @"transdocId":_dataSource[sec - 1][@"doc_id"]};
    }
    
    [AvailableNetWorking postWithUrl:docDelete_connector params:params successHandler:^(id responseObject) {
        
        if ([responseObject[@"code"] integerValue] == 200 || [responseObject[@"code"] integerValue] == 400 || [responseObject[@"code"] integerValue] == 402) {
            if ([responseObject[@"code"] integerValue] == 200) {
                NSLog(@"UUID == %@",responseObject[@"result"]);
                [self deleteDocWithUUID:responseObject[@"result"]];
            }else{
                [LSProgressHUD hideForWindow];
                [TopAlertView SetUpbackgroundColor:AlertRedColor andStayTime:2.0 andImageName:@"imagePlaceholder" andTitleStr:@"删除文稿失败" andTitleColor:[UIColor whiteColor] andCancel:NO];
                [self fileEditCancelNofifiCationClicked];
                [JeemaaNotificationCenter postNotificationName:@"hideCusOpreationView" object:nil];
            }
        }else{
            [self WhenDeleteDocGetUUIDWithSec:sec batch:batch];
        }
        
    } falureHandler:^(NSError *error) {
        
    }];
}

//获取文件的UUID
- (void)deleteDocWithUUID:(NSString *)uuid{

    NSDictionary *params = @{@"uuid":uuid};
    [AvailableNetWorking postWithUrl:docDeleteResult_connector params:params successHandler:^(id responseObject) {
        
        if ([responseObject[@"code"] integerValue] == 200 || [responseObject[@"code"] integerValue] == 400 || [responseObject[@"code"] integerValue] == 202) {
            if ([responseObject[@"code"] integerValue] == 200 || [responseObject[@"code"] integerValue] == 202) {
                [TopAlertView SetUpbackgroundColor:mainColor andStayTime:2.0 andImageName:@"imagePlaceholder" andTitleStr:@"删除文稿成功" andTitleColor:[UIColor whiteColor] andCancel:NO];
                //更新数据
                [_dataSource removeAllObjects];
                [self getFinderListRequest];
            }
            else{
                [TopAlertView SetUpbackgroundColor:AlertRedColor andStayTime:2.0 andImageName:@"imagePlaceholder" andTitleStr:@"删除文稿失败" andTitleColor:[UIColor whiteColor] andCancel:NO];
            }
            [LSProgressHUD hideForWindow];
            [self fileEditCancelNofifiCationClicked];
            [JeemaaNotificationCenter postNotificationName:@"hideCusOpreationView" object:nil];
        }
        else{
            
            [self deleteDocWithUUID:uuid];
        }
        
    } falureHandler:^(NSError *error) {
        
    }];
}

#pragma mark -- AssignTaskDelegate

- (void)AssignTaskButton:(UIButton *)sender andUserId:(NSInteger)userId{
    
    [[UIApplication sharedApplication].keyWindow addSubview:self.selectTranslatorView];
    __weak typeof(self) weakSelf = self;
    self.selectTranslatorView.selectTranslatorBlock = ^(MJ_SelectTranslatorType type) {
        __strong typeof(weakSelf) strongSelf = weakSelf;
        switch (type) {
            case MJ_SelectTranslatorTypeGroup:
                [strongSelf.selectTranslatorView removeFromSuperview];
                [strongSelf assignTaskButton:sender andUserId:userId];
                break;
            case MJ_SelectTranslatorTypetalentPool:
            {
                [strongSelf publishTaskWithButton:sender userId:userId];//跳转到发布任务
            }
                break;
            default:
                [strongSelf.selectTranslatorView removeFromSuperview];
                break;
        }
    };
}
//跳转到发布任务
-(void)publishTaskWithButton:(UIButton *)sender userId:(NSInteger)userId {
    
    [self.selectTranslatorView removeFromSuperview];
    MJ_EditTaskInfoViewController *vc = [[MJ_EditTaskInfoViewController alloc] init];
    UITableViewCell *cell = (UITableViewCell *)sender.superview;
    NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
    vc.docId = [NSString stringWithFormat:@"%@",_dataSource[indexPath.section - 1][@"doc_id"]];
    vc.endRownum = [NSString stringWithFormat:@"%@",_dataSource[indexPath.section - 1][@"result"][indexPath.row][@"end_rownum"]];
    vc.sectorId = [NSString stringWithFormat:@"%@",_dataSource[indexPath.section - 1][@"result"][indexPath.row][@"sectorId"]];
    vc.wordcount = [NSString stringWithFormat:@"%@",_dataSource[indexPath.section - 1][@"result"][indexPath.row][@"wordcount"]];
    if (userId == 1) {
        vc.translateType = @"翻译";
    }else if (userId == 2) {
        vc.translateType = @"编辑";
    }else{
        vc.translateType = @"校对";
    }
    [self.navigationController pushViewController:vc animated:YES];
}

- (void)assignTaskButton:(UIButton *)sender andUserId:(NSInteger)userId {
    [sender setEnabled:NO];
    UITableViewCell *cell = (UITableViewCell *)sender.superview;
    NSIndexPath *indexPath = [self.tableView indexPathForCell:cell];
    NSLog(@"dataSource = %@",_dataSource[indexPath.section - 1][@"result"]);

    if ([detailsModel.nowStep integerValue] > 0 && [detailsModel.nowStep integerValue] < 5) {
        AppDelegate *tempAppDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
        [tempAppDelegate.window.rootViewController.view addSubview:self.shadowView];
        self.isSureHud.textLabel.text = @"该项目还在流程中，请到网页上操作";
        [self.shadowView addSubview:self.isSureHud];
        self.isSureHud.center = CGPointMake(self.view.center.x, -500);
        [UIView animateWithDuration:0.6 animations:^{
            self.isSureHud.center = self.view.center;
        }];
        [sender setEnabled:YES];
    }
    else if ([_dataSource[indexPath.section - 1][@"isPay"] integerValue] == 1 && [_dataSource[indexPath.section - 1][@"payStatus"] integerValue] == 0){
        
        [TopAlertView SetUpbackgroundColor:AlertRedColor andStayTime:2.0 andImageName:@"imagePlaceholder" andTitleStr:@"该文档付费后，才能指定任务。" andTitleColor:[UIColor whiteColor] andCancel:NO];
        
    }
    else{
        
        [sender setEnabled:NO];
        NSLog(@"indexPath.section == %ld, indexPath.row == %ld",(long)indexPath.section,(long)indexPath.row);
        self.hidesBottomBarWhenPushed = YES;
        AssigningViewController *VC = [[AssigningViewController alloc]init];
        
        VC.owner_id = detailsModel.ownerId;
        VC.languageType = detailsModel.dataSource_head[0];
        shareData.team_Id = detailsModel.ownerId;
        
        //#pragma mark ------- 传递派稿必须信息
        VC.userType = [NSString stringWithFormat:@"%ld",(long)userId];
        
        if (((NSArray *)_dataSource[indexPath.section - 1][@"result"]).count == 0) {
            VC.trans_userId = [NSString stringWithFormat:@"%@",_dataSource[indexPath.row][@"interpreterUserId"]];
            VC.edit_userId = [NSString stringWithFormat:@"%@",_dataSource[indexPath.row][@"editUserId"]];
            VC.pro_userId = [NSString stringWithFormat:@"%@",_dataSource[indexPath.row][@"proofreadUserId"]];
            
            VC.transBlockId = [NSString stringWithFormat:@"%d",-1];
            VC.end_rownum = [NSString stringWithFormat:@"%@",_dataSource[indexPath.section -1][@"end_rownum"]];
            VC.transDocId = [NSString stringWithFormat:@"%@",_dataSource[indexPath.section -1][@"doc_id"]];
            VC.transDocName = _dataSource[indexPath.section -1][@"doc_name"];
            
            if ([_dataSource[indexPath.row][@"interpreterUserId"] integerValue] == -1 ) {
                //正在自动派稿中
                switch (userId) {
                    case 1:
                    {
                        NSLog(@"取消自动派稿");
                        _cancelParam = @{@"transDocId":[NSString stringWithFormat:@"%@",_dataSource[indexPath.section -1][@"doc_id"]],
                                         @"projectId":shareData.product_Id,
                                         @"sectorId":[NSString stringWithFormat:@"%d",-1]};
                        AppDelegate *tempAppDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
                        [tempAppDelegate.window.rootViewController.view addSubview:self.shadowView];
                        [self.shadowView addSubview:self.cancelHud];
                        self.cancelHud.center = CGPointMake(self.view.center.x, -500);
                        [UIView animateWithDuration:0.6 animations:^{
                            self.cancelHud.center = self.view.center;
                        }];
                    }
                        break;
                    case 2:
                    {
                        [TopAlertView SetUpbackgroundColor:AlertRedColor andStayTime:2.0 andImageName:@"imagePlaceholder" andTitleStr:@"有翻译任务未分配，无法分配编辑任务" andTitleColor:[UIColor whiteColor] andCancel:NO];
                    }
                        break;
                    case 3:
                    {
                        [TopAlertView SetUpbackgroundColor:AlertRedColor andStayTime:2.0 andImageName:@"imagePlaceholder" andTitleStr:@"有翻译或编辑任务未分配，无法分配校对任务" andTitleColor:[UIColor whiteColor] andCancel:NO];
                    }
                        break;
                    default:
                        break;
                }
                
            }else if ([_dataSource[indexPath.row][@"interpreterUserId"] integerValue] == -2){
                
                AppDelegate *tempAppDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
                [tempAppDelegate.window.rootViewController.view addSubview:self.shadowView];
                [self.shadowView addSubview:self.isSureHud];
                self.isSureHud.center = CGPointMake(self.view.center.x, -500);
                [UIView animateWithDuration:0.6 animations:^{
                    self.isSureHud.center = self.view.center;
                }];
                
                
                
            }else{
                switch (userId) {
                    case 1:
                    {
                        [self getNextSectionInfoRequestWithSender:sender andVc:VC];
                        VC.compelateTime = [NSString stringWithFormat:@"%@",_dataSource[indexPath.section -1][@"interpreterCompleteTime"]];
                    }
                        break;
                    case 2:
                    {
                        if ([_dataSource[indexPath.row][@"interpreterUserId"] integerValue] > 0) {
                            [self getNextSectionInfoRequestWithSender:sender andVc:VC];
                            VC.compelateTime = [NSString stringWithFormat:@"%@",_dataSource[indexPath.section -1][@"editCompleteTime"]];
                        }else{
                            
                            [TopAlertView SetUpbackgroundColor:AlertRedColor andStayTime:2.0 andImageName:@"imagePlaceholder" andTitleStr:@"有翻译任务未分配，无法分配编辑任务" andTitleColor:[UIColor whiteColor] andCancel:NO];
                            
                        }
                        
                    }
                        break;
                    case 3:
                    {
                        if ([_dataSource[indexPath.row][@"editUserId"] integerValue] > 0) {
                            [self getNextSectionInfoRequestWithSender:sender andVc:VC];
                            VC.compelateTime = [NSString stringWithFormat:@"%@",_dataSource[indexPath.section -1][@"proofreadCompleteTime"]];
                        }else{
                            [TopAlertView SetUpbackgroundColor:AlertRedColor andStayTime:2.0 andImageName:@"imagePlaceholder" andTitleStr:@"有翻译或编辑任务未分配，无法分配校对任务" andTitleColor:[UIColor whiteColor] andCancel:NO];
                        }
                    }
                        break;
                    default:
                        break;
                }
            }
            
        }
        else{
            
            VC.trans_userId = [NSString stringWithFormat:@"%@",_dataSource[indexPath.section - 1][@"result"][indexPath.row][@"interpreterUserId"]];
            VC.edit_userId = [NSString stringWithFormat:@"%@",_dataSource[indexPath.section - 1][@"result"][indexPath.row][@"editUserId"]];
            VC.pro_userId = [NSString stringWithFormat:@"%@",_dataSource[indexPath.section - 1][@"result"][indexPath.row][@"proofreadUserId"]];
            VC.end_rownum = _dataSource[indexPath.section - 1][@"result"][indexPath.row][@"end_rownum"];
            VC.transDocId = [NSString stringWithFormat:@"%@",_dataSource[indexPath.section-1][@"doc_id"]];
            VC.transDocName = _dataSource[indexPath.section - 1][@"result"][indexPath.row][@"sectorname"];
            VC.transBlockId = [NSString stringWithFormat:@"%@",_dataSource[indexPath.section - 1][@"result"][indexPath.row][@"sectorId"]];
            
            if ([_dataSource[indexPath.section - 1][@"result"][indexPath.row][@"interpreterUserId"] integerValue] == -1 ) {
                //正在自动派稿中
                switch (userId) {
                    case 1:
                    {
                        NSLog(@"取消自动派稿");
                        _cancelParam = @{@"transDocId":[NSString stringWithFormat:@"%@",_dataSource[indexPath.section-1][@"doc_id"]],
                                         @"projectId":shareData.product_Id,
                                         @"sectorId":[NSString stringWithFormat:@"%@",_dataSource[indexPath.section - 1][@"result"][indexPath.row][@"sectorId"]]};
                        AppDelegate *tempAppDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
                        [tempAppDelegate.window.rootViewController.view addSubview:self.shadowView];
                        [self.shadowView addSubview:self.cancelHud];
                        self.cancelHud.center = CGPointMake(self.view.center.x, -500);
                        [UIView animateWithDuration:0.6 animations:^{
                            self.cancelHud.center = self.view.center;
                        }];
                    }
                        break;
                    case 2:
                    {
                        [TopAlertView SetUpbackgroundColor:AlertRedColor andStayTime:2.0 andImageName:@"imagePlaceholder" andTitleStr:@"有翻译任务未分配，无法分配编辑任务" andTitleColor:[UIColor whiteColor] andCancel:NO];
                    }
                        break;
                    case 3:
                    {
                        [TopAlertView SetUpbackgroundColor:AlertRedColor andStayTime:2.0 andImageName:@"imagePlaceholder" andTitleStr:@"有翻译或编辑任务未分配，无法分配校对任务" andTitleColor:[UIColor whiteColor] andCancel:NO];
                    }
                        break;
                    default:
                        break;
                }
                
            }else if ([_dataSource[indexPath.section - 1][@"result"][indexPath.row][@"interpreterUserId"] integerValue] == -2){
                
                AppDelegate *tempAppDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
                [tempAppDelegate.window.rootViewController.view addSubview:self.shadowView];
                [self.shadowView addSubview:self.isSureHud];
                self.isSureHud.center = CGPointMake(self.view.center.x, -500);
                [UIView animateWithDuration:0.6 animations:^{
                    self.isSureHud.center = self.view.center;
                }];
            }else{
                
                switch (userId) {
                    case 1:
                    {
                        [self getNextSectionInfoRequestWithSender:sender andVc:VC];
                        VC.compelateTime = [NSString stringWithFormat:@"%@",_dataSource[indexPath.section - 1][@"result"][indexPath.row][@"interpreterCompleteTime"]];
                    }
                        break;
                    case 2:
                    {
                        if ([_dataSource[indexPath.section - 1][@"result"][indexPath.row][@"interpreterUserId"] integerValue] > 0) {
                            [self getNextSectionInfoRequestWithSender:sender andVc:VC];
                            VC.compelateTime = [NSString stringWithFormat:@"%@",_dataSource[indexPath.section - 1][@"result"][indexPath.row][@"editCompleteTime"]];
                        }else{
                            [TopAlertView SetUpbackgroundColor:AlertRedColor andStayTime:2.0 andImageName:@"imagePlaceholder" andTitleStr:@"有翻译任务未分配，无法分配编辑任务" andTitleColor:[UIColor whiteColor] andCancel:NO];
                            
                        }
                    }
                        break;
                    case 3:
                    {
                        if ([_dataSource[indexPath.section - 1][@"result"][indexPath.row][@"editUserId"] integerValue] > 0) {
                            [self getNextSectionInfoRequestWithSender:sender andVc:VC];
                            VC.compelateTime = [NSString stringWithFormat:@"%@",_dataSource[indexPath.section - 1][@"result"][indexPath.row][@"proofreadCompleteTime"]];
                        }else{
                            [TopAlertView SetUpbackgroundColor:AlertRedColor andStayTime:2.0 andImageName:@"imagePlaceholder" andTitleStr:@"有翻译或编辑任务未分配，无法分配校对任务" andTitleColor:[UIColor whiteColor] andCancel:NO];
                        }
                    }
                        break;
                    default:
                        break;
                }
            }
        }
    }
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.6 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
        [sender setEnabled:YES];
    });
}

#pragma mark -- <cancelHudDelegate,IsureHudDelegate>

- (void)cancelHudClicked:(UIButton *)sender{
    
    if ([sender.titleLabel.text isEqualToString:@"继续派稿"]) {
        
        [UIView animateWithDuration:0.6 animations:^{
            self.cancelHud.center = CGPointMake(self.view.center.x, 1000);
            
        } completion:^(BOOL finished) {
            [self.cancelHud removeFromSuperview];
            [self.shadowView removeFromSuperview];
        }];
        
        
    }else if ([sender.titleLabel.text isEqualToString:@"停止派稿"]){
        
        [UIView animateWithDuration:0.6 animations:^{
            self.cancelHud.center = CGPointMake(self.view.center.x, 1000);
            
        } completion:^(BOOL finished) {
            [self.cancelHud removeFromSuperview];
            [self.shadowView removeFromSuperview];
        }];
        
        [AvailableNetWorking postWithUrl:cancelTask_connector params:_cancelParam successHandler:^(id responseObject) {
            
            NSLog(@"%@",responseObject);
            if ([responseObject[@"code"] integerValue] == 200) {
                //刷新数据--
                [_dataSource removeAllObjects];
                [self getFinderListRequest];
                [TopAlertView SetUpbackgroundColor:AlertRedColor andStayTime:2.0 andImageName:@"imagePlaceholder" andTitleStr:@"取消自动派稿成功！" andTitleColor:[UIColor whiteColor] andCancel:NO];
            }else{
                [TopAlertView SetUpbackgroundColor:AlertRedColor andStayTime:2.0 andImageName:@"imagePlaceholder" andTitleStr:responseObject[@"message"] andTitleColor:[UIColor whiteColor] andCancel:NO];
                
            }
        } falureHandler:^(NSError *error) {
            
        }];
    }
}

- (void)IsureHudClicked:(UIButton *)sender{
    
    [UIView animateWithDuration:0.6 animations:^{
        self.isSureHud.center = CGPointMake(self.view.center.x, 1000);
        
    } completion:^(BOOL finished) {
        [self.isSureHud removeFromSuperview];
        [self.shadowView removeFromSuperview];
    }];
    
}

- (void)showHudViewWithText:(NSString *)text{
    
    [TopAlertView SetUpbackgroundColor:mainColor andStayTime:2.0 andImageName:@"imagePlaceholder" andTitleStr:text andTitleColor:[UIColor whiteColor] andCancel:NO];
}

- (void)getNextSectionInfoRequestWithSender:(UIButton *)sender andVc:(UIViewController *)VC{
    
    //获取下个页面必需的数据信息
    [AvailableNetWorking postWithUrl:groups_connector params:@{@"teamId":shareData.team_Id} successHandler:^(id responseObject) {
        NSMutableArray *titles = [NSMutableArray array];
        if ([responseObject[@"code"] intValue] == 200) {
            NSArray *arr = responseObject[@"result"];
            [arr enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
                [titles addObject:obj[@"groupName"]];
            }];
            [titles addObject:@"分组"];
            shareData.sectiontitles = titles.count;
            self.parentViewController.hidesBottomBarWhenPushed = YES;
            [self.navigationController pushViewController:VC animated:YES];
            [sender setEnabled:YES];
            
        }else{
            NSLog(@"分组信息获取失败");
            [sender setEnabled:YES];
            
        }
    } falureHandler:^(NSError *error) {
        NSLog(@"分组信息获取失败");
        [sender setEnabled:YES];
        
    }];
    
}

#pragma mark -- private
#pragma mark -- 计算宽窄的函数
-(float)autoCalculateWidthOrHeight:(float)height
                             width:(float)width
                          fontsize:(float)fontsize
                           content:(NSString*)content
{
    //计算出rect
    CGRect rect = [content boundingRectWithSize:CGSizeMake(width, height)
                                        options:NSStringDrawingUsesLineFragmentOrigin | NSStringDrawingUsesFontLeading
                                     attributes:@{NSFontAttributeName:[UIFont systemFontOfSize:fontsize]} context:nil];
    
    //判断计算的是宽还是高
    if (height == MAXFLOAT) {
        return rect.size.height;
    }
    else
        return rect.size.width;
}

- (CGSize)labelheight:(UILabel *)detlabel
{
    CGSize size = CGSizeMake(180, MAXFLOAT);
    
    CGSize contentactually = [detlabel.text boundingRectWithSize:size options:(NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading) attributes:[NSDictionary dictionaryWithObjectsAndKeys:detlabel.font,NSFontAttributeName,nil] context:nil].size;
    return contentactually;
}

#pragma mark -- 判断名字

- (NSString *)judeNameWithString:(NSString *)string{
    
    if (!string) {
        return @"未指派";
    }else{
        
        return string;
    }
}

#pragma mark -- 判断后缀

- (NSString *)judgeTypeWithName:(NSString *)string{
    
    NSArray *array = [string componentsSeparatedByString:@"."];
    if ([array.lastObject isEqualToString:@"doc"] || [array.lastObject isEqualToString:@"docx"] || [array.lastObject isEqualToString:@"rtf"]) {
        
        return @"word";
    }
    else if ([array.lastObject isEqualToString:@"xls"] || [array.lastObject isEqualToString:@"xlsx"]){
        
        return @"Exel";
    }
    else if ([array.lastObject isEqualToString:@"ppt"] || [array.lastObject isEqualToString:@"pptx"]){
        
        return @"ppt";
    }
    else if ([array.lastObject isEqualToString:@"dwg"] || [array.lastObject isEqualToString:@"dxf"]){
        
        return @"CAD";
    }
    else if ([array.lastObject isEqualToString:@"vsdx"]){
        
        return @"vsdx";
    }
    else if ([array.lastObject isEqualToString:@"sdlxliff"]){
        
        return @"sdlxliff";
    }
    else if ([array.lastObject isEqualToString:@"xmind"]){
        return @"xmind";
    }
    else{
        
        return @"pdf";
    }
}

#pragma mark -- 判断有几个拆分文件

- (NSInteger)judgeRowInsectionWithData:(NSDictionary *)data section:(NSInteger)section{
    
    _index = 0;
    NSArray *keys = [NSArray arrayWithArray:[data allKeys]];
    [keys enumerateObjectsUsingBlock:^(id  _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
        NSString *string = [NSString stringWithFormat:@"%@",obj];
        if ([string isEqualToString:@"result"]) {
            NSArray *resultNew = _dataSource[section][@"result"];
            if (resultNew.count == 0) {
                _index = 1;
            }else{
                _index = resultNew.count;
            }
        }
    }];
    
    return _index;
}

#pragma mark judeNullUserID ---

- (id)judgeNullUserIdWithObj:(id)obj{
    
    if (obj) {
        NSString *temp = [NSString stringWithFormat:@"%@",obj];
        
        if ([temp isEqualToString:@"(null)"] || [obj isEqual:[NSNull null]]) {
            return @"null";
        }
        else{
            
            return obj;
        }
        
    }else{
        
        return @"null";
    }
}

#pragma mark judeNUll---

- (NSString *)judeNullWithString:(NSString *)string{
    
    if ([string isEqualToString:@""]) {
        return @"00-00 00:00";
    }
    else{
        
        return [[NSString stringWithFormat:@"%@",string] substringFromIndex:5];
    }
}

#pragma mark -- judgeFloat
- (CGFloat)judeNullFloatWithString:(id)obj{
    
    if (obj) {
        if ([obj isEqual:[NSNull null]]) {
            CGFloat num = 0;
            return num;
        }
        else{
            
            CGFloat num = [obj floatValue];
            return num/100 ;
        }
        
    }else{
        
        return 0;
    }
}

#pragma mark -- judgeNaN

- (CGFloat)judgeNanMethodWithNum:(CGFloat)num{
    
    return isnan(num) ? 0 :num;
}

#pragma mark -- 重新组装数据

//- (NSArray *)regroupDataByDataSource:(NSArray *)dataSource{
//
//    NSArray *keys = [NSArray arrayWithArray:[dataSource allKeys]];
//}

#pragma mark -- getter

- (UITableView *)tableView{
    
    if (!_tableView) {
        _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, Screen_Width, Screen_Height-103) style:UITableViewStyleGrouped];
        _tableView.rowHeight = 230*Radio;
        _tableView.backgroundColor = RGB(225, 225, 225, 1);
        _tableView.dataSource = self;
        _tableView.delegate = self;
        _tableView.separatorColor = [UIColor clearColor];
        _tableView.scrollEnabled = YES;
        _tableView.bounces = YES;
    }
    return _tableView;
}

- (UITableView *)tableView_head{
    
    if (!_tableView_head) {
        _tableView_head = [[UITableView alloc]initWithFrame:CGRectMake(10, 0, Screen_Width-20,370) style:UITableViewStylePlain];
        _tableView_head.backgroundColor = RGB(245, 246, 247, 1);
        _tableView_head.dataSource = self;
        _tableView_head.delegate = self;
        _tableView_head.separatorColor = [UIColor whiteColor];
        _tableView_head.scrollEnabled = NO;
        _tableView_head.bounces = NO;
    }
    return _tableView_head;
}

- (UIView *)shadowView{
    
    if (!_shadowView) {
        _shadowView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, Screen_Width, Screen_Height)];
        _shadowView.backgroundColor = [UIColor colorWithWhite:1 alpha:0];
    }
    return _shadowView;
}

- (CancelTaskHud *)cancelHud{
    
    if (!_cancelHud) {
        _cancelHud = [[CancelTaskHud alloc]initWithFrame:CGRectMake(0, 0, Screen_Width-40*Radio, Screen_Width - 40*Radio -50*Radio)];
        _cancelHud.center = CGPointMake(self.view.center.x, -500);
        _cancelHud.delegate = self;
    }
    return _cancelHud;
}

- (IsureTaskHud *)isSureHud{
    
    if (!_isSureHud) {
        _isSureHud = [[IsureTaskHud alloc]initWithFrame:CGRectMake(0, 0, Screen_Width-40*Radio, Screen_Width - 40*Radio -80*Radio)];
        _isSureHud.center = CGPointMake(self.view.center.x, -500);
        _isSureHud.delegate = self;
    }
    return _isSureHud;
}

- (UIView *)tempView{
    
    if (!_tempView) {
        _tempView = [[UIView alloc]initWithFrame:CGRectMake(0, 400*Radio, Screen_Width, Screen_Height-400*Radio)];
        _tempView.backgroundColor = [UIColor colorWithWhite:0 alpha:0.3];
    }
    return _tempView;
}

- (UIView *)ToolsView{
    
    if (!_ToolsView) {
        _ToolsView = [[UIView alloc]initWithFrame:CGRectMake(0, Screen_Height-104, Screen_Width, 50)];
        _ToolsView.backgroundColor = RGB(39, 181, 238, 1);
        _ToolsView.userInteractionEnabled = YES;
    }
    return _ToolsView;
}

- (UIImageView *)view_data_nil{
    
    if (!_view_data_nil) {
        _view_data_nil = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, Screen_Width/2+50*Radio, Screen_Width/2)];
        _view_data_nil.image = [UIImage imageNamed:@"任务"];
        _view_data_nil.center = CGPointMake(self.view.center.x, Screen_Height/4);
    }
    return _view_data_nil;
}

- (UILabel *)text_data_nil{
    
    if (!_text_data_nil) {
        _text_data_nil = [[UILabel alloc]initWithFrame:CGRectMake(0, _view_data_nil.frame.origin.y+_view_data_nil.frame.size.height+20*Radio, Screen_Width, 30)];
        _text_data_nil.backgroundColor = [UIColor clearColor];
        _text_data_nil.text = @"暂时没有文件";
        _text_data_nil.font = [UIFont systemFontOfSize:FLEXIBLE(18)];
        _text_data_nil.textColor = [UIColor grayColor];
        _text_data_nil.textAlignment = NSTextAlignmentCenter;
    }
    return _text_data_nil;
}

@end
